const showMsgEle = document.getElementById("show-msg");
const inputMsgEle = document.getElementById("input-msg-ele");
const sendMsgBtn = document.getElementById("send-msg-btn");

window.addEventListener("storage", function (e) {
  console.log(e);
  if (e.key === "share-msg") {
    const data = JSON.parse(e.newValue);
    showMsgEle.value = data.msg;
  }
});

sendMsgBtn.addEventListener("click", function () {
  localStorage.setItem(
    "share-msg",
    JSON.stringify({
      from: document.title,
      msg: inputMsgEle.value,
      st: +new Date(),
    })
  );
});
